package alkaid.eis.sys.service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import org.springframework.data.jpa.domain.Specification;

import alkaid.eis.sys.entity.Option;
import lombok.experimental.UtilityClass;

/**
 * 设置项查询条件
 *  
 * @author Lucky Yang
 * @since 0.0.1
 */
@UtilityClass
public class OptionSpecifications {
    public Specification<Option> empty() {
        return (Root<Option> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
            return null;
        };
    }

    public Specification<Option> descriptionLike(String description) {
        return (Root<Option> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
            return cb.like(root.get("description"), "%" + description + "%");
        };
    } 
}
